CarPhysics Class Reference

#include <CarPhysics.h>

Inheritance diagram for CarPhysics:

PhysicsClient List of all members.

Public Member Functions

 CarPhysics (Vehicle &vehicle)
virtual ~CarPhysics ()
virtual double update (double step)
virtual void odeDraw ()
bool create (const CarData *carDataPtr, osg::ref_ptr< osg::PositionAttitudeTransform > objectPAT)
void setSteering (double steer)
void setAccelleration (double acl)
void setGear (int gear)
double getSpeed ()
double getTraction ()
const Vector3 & getPosition ()
const double * getRotation ()
void setPosition (double x, double y, double z)
void setRotation (double x, double y, double z)
void mySetPosition ()
Vehicle * getOSGVehicle ()

Protected Member Functions

void positionCar (double x, double y, double z)
const double * getGeomPosition (dGeomID geom)
const double * getGeomRotation (dGeomID geom)
void addGeom (dGeomID geom, dReal xoff, dReal yoff, dReal zoff, dMatrix3 R)

Protected Attributes

const CarData * _pCarData
double _steering
double _accel
double _speed
double _traction
double _chassisHgt
double _gearMod
dBodyID _carBody
dBodyID _wheelBody [4]
dJointID _joint [4]
dSpaceID _carSpace
vector< dGeomID > _carGeoms
dGeomID _wheelGeom [4]
PhysGeomData _wheelData
Vehicle OSGvehicle

Detailed Description

CarPhysics.h: interface for the CarPhysics class.

Definition at line 5 of file CarPhysics.h.


Constructor & Destructor Documentation

CarPhysics::CarPhysics (  Vehicle &  vehicle  ) 
 

A constructor with one argument.

Parameters:
vehicle a Vehicle refrence.

Definition at line 6 of file CarPhysics.cpp.

References _accel, _carBody, _carSpace, _chassisHgt, _gearMod, _joint, _speed, _steering, _traction, _wheelBody, _wheelGeom, and OSGvehicle.

CarPhysics::~CarPhysics (   )  [virtual]
 

A destructor.

Definition at line 1 of file CarPhysics.cpp.


Member Function Documentation

void CarPhysics::addGeom (  dGeomID  geom,
dReal  xoff,
dReal  yoff,
dReal  zoff,
dMatrix3  R
)  [protected]
 

Definition at line 417 of file CarPhysics.cpp.

References _carBody, _carGeoms, and _carSpace.

Referenced by create().

bool CarPhysics::create (  const CarData *  carDataPtr,
osg::ref_ptr< osg::PositionAttitudeTransform >  objectPAT
) 
 

a normal member taking two arguments and returning a bool.

Parameters:
carDataPtr a pointer to CarData.
objectPAT a osg::ref_ptr to osg::PositionAttitudeTransform.
Returns:
true if successful set car parameters and create all bodies and geometries

Definition at line 42 of file CarPhysics.cpp.

References _carBody, _carSpace, _chassisHgt, _pCarData, PhysicsClient::_space, _wheelBody, _wheelData, _wheelGeom, PhysicsClient::_world, and addGeom().

Referenced by AnimationWindow::createCarPhysics().

const double * CarPhysics::getGeomPosition (  dGeomID  geom  )  [protected]
 

a protected member taking one arguments and returning const double *.

Parameters:
geom a dGeomID argument.
Returns:
const double*. returns position for a specific geom.

Definition at line 355 of file CarPhysics.cpp.

Referenced by getPosition().

const double * CarPhysics::getGeomRotation (  dGeomID  geom  )  [protected]
 

Definition at line 379 of file CarPhysics.cpp.

Referenced by getRotation().

Vehicle * CarPhysics::getOSGVehicle (   ) 
 

Definition at line 561 of file CarPhysics.cpp.

References OSGvehicle.

const Vector3 & CarPhysics::getPosition (   ) 
 

Definition at line 276 of file CarPhysics.cpp.

References _carGeoms, and getGeomPosition().

const double * CarPhysics::getRotation (   ) 
 

Definition at line 290 of file CarPhysics.cpp.

References _carGeoms, and getGeomRotation().

double CarPhysics::getSpeed (   ) 
 

Definition at line 263 of file CarPhysics.cpp.

References _carBody.

double CarPhysics::getTraction (   )  [inline]
 

Definition at line 42 of file CarPhysics.h.

References _traction.

void CarPhysics::mySetPosition (   ) 
 

Definition at line 398 of file CarPhysics.cpp.

References TraffEduObject::getObjectPATvector(), Vehicle::getPath(), Path::getPointVector(), OSGvehicle, setPosition(), and setRotation().

void CarPhysics::odeDraw (   )  [virtual]
 

A virtual member. updates simulation state.

Implements PhysicsClient.

Definition at line 440 of file CarPhysics.cpp.

References _carBody, _carGeoms, TraffEduObject::getObjectPAT(), and OSGvehicle.

void CarPhysics::positionCar (  double  x,
double  y,
double  z
)  [protected]
 

a protected member taking three arguments and returning void.

Parameters:
x a double argument for x coordinate of the car.
y a double argument for y coordinate of the car.
z a double argument for z coordinate of the car. position entire car (global world coordinates)

Definition at line 326 of file CarPhysics.cpp.

References _carBody, and _wheelBody.

Referenced by setPosition().

void CarPhysics::setAccelleration (  double  acl  )  [inline]
 

Definition at line 38 of file CarPhysics.h.

References _accel.

void CarPhysics::setGear (  int  gear  ) 
 

Definition at line 250 of file CarPhysics.cpp.

References _gearMod.

void CarPhysics::setPosition (  double  x,
double  y,
double  z
) 
 

Definition at line 297 of file CarPhysics.cpp.

References positionCar().

Referenced by mySetPosition().

void CarPhysics::setRotation (  double  x,
double  y,
double  z
) 
 

Definition at line 305 of file CarPhysics.cpp.

References _carBody, and _wheelBody.

Referenced by mySetPosition().

void CarPhysics::setSteering (  double  steer  )  [inline]
 

Definition at line 37 of file CarPhysics.h.

References _steering.

double CarPhysics::update (  double  step  )  [virtual]
 

A virtual member.

Parameters:
step double step size.

Implements PhysicsClient.

Definition at line 183 of file CarPhysics.cpp.

References _accel, _gearMod, _joint, _pCarData, PhysicsClient::_space, _speed, and PhysicsClient::_world.


Member Data Documentation

double CarPhysics::_accel [protected]
 

a protected variable. current acceleration.

Definition at line 88 of file CarPhysics.h.

Referenced by CarPhysics(), setAccelleration(), and update().

dBodyID CarPhysics::_carBody [protected]
 

a protected variable. body id of vehicle.

Definition at line 112 of file CarPhysics.h.

Referenced by addGeom(), CarPhysics(), create(), getSpeed(), odeDraw(), positionCar(), and setRotation().

vector<dGeomID> CarPhysics::_carGeoms [protected]
 

a protected variable. vector for car geometries (actually dGeomTransforms).

Definition at line 134 of file CarPhysics.h.

Referenced by addGeom(), getPosition(), getRotation(), and odeDraw().

dSpaceID CarPhysics::_carSpace [protected]
 

a protected variable. space for car geometries.

Definition at line 129 of file CarPhysics.h.

Referenced by addGeom(), CarPhysics(), and create().

double CarPhysics::_chassisHgt [protected]
 

a protected variable. height of chassis.

Definition at line 100 of file CarPhysics.h.

Referenced by CarPhysics(), and create().

double CarPhysics::_gearMod [protected]
 

a protected variable. gear modifier, used for gear switching (transmission).

Definition at line 105 of file CarPhysics.h.

Referenced by CarPhysics(), setGear(), and update().

dJointID CarPhysics::_joint[4] [protected]
 

a protected variable. joint ids of vehicle wheels.

Definition at line 123 of file CarPhysics.h.

Referenced by CarPhysics(), and update().

const CarData* CarPhysics::_pCarData [protected]
 

a protected variable. struct for car attributes.

Definition at line 78 of file CarPhysics.h.

Referenced by create(), and update().

double CarPhysics::_speed [protected]
 

a protected variable. current car speed.

Definition at line 93 of file CarPhysics.h.

Referenced by CarPhysics(), and update().

double CarPhysics::_steering [protected]
 

a protected variable. current steering (-1=left 1=right).

Definition at line 83 of file CarPhysics.h.

Referenced by CarPhysics(), and setSteering().

double CarPhysics::_traction [protected]
 

Definition at line 95 of file CarPhysics.h.

Referenced by CarPhysics(), and getTraction().

dBodyID CarPhysics::_wheelBody[4] [protected]
 

a protected variable. body ids of vehicle wheels.

Definition at line 117 of file CarPhysics.h.

Referenced by CarPhysics(), create(), positionCar(), and setRotation().

PhysGeomData CarPhysics::_wheelData [protected]
 

Definition at line 140 of file CarPhysics.h.

Referenced by create().

dGeomID CarPhysics::_wheelGeom[4] [protected]
 

a protected variable. geom for each wheel.

Definition at line 139 of file CarPhysics.h.

Referenced by CarPhysics(), and create().

Vehicle CarPhysics::OSGvehicle [protected]
 

Definition at line 141 of file CarPhysics.h.

Referenced by CarPhysics(), getOSGVehicle(), mySetPosition(), and odeDraw().


The documentation for this class was generated from the following files:
Generated on Sun May 28 18:54:12 2006 for TraffEdu by  doxygen 1.4.6-NO